package logic

import (
	"api/model/mysql"
	"context"
	"house_srv/house"
	"house_srv/internal/svc"

	"github.com/zeromicro/go-zero/core/logx"
)

type UpdateStatusLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewUpdateStatusLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateStatusLogic {
	return &UpdateStatusLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *UpdateStatusLogic) UpdateStatus(in *house.UpdateStatusRequest) (*house.UpdateStatusResponse, error) {
	// todo: add your logic here and delete this line

	var o mysql.Order
	mysql.DB.Find(&o)

	err := o.Update(in.OrderSn, int(in.HouseStatus))
	if err != nil {
		logx.Error("修改状态失败")
		return nil, err
	}

	return &house.UpdateStatusResponse{}, nil
}
